﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace System
{
    public static class TypeExtensions
    {
        public static bool SupportInterface(this Type type, Type inter)
        {
            if (inter.IsAssignableFrom(type))
            {
                return true;
            }
            if (type.GetInterfaces().Any(i => i.IsGenericType && i.GetGenericTypeDefinition() == inter))
            {
                return true;
            }

            return false;
        }

        public static bool IsModuleType(this Type type, params Type[] baseTypes)
        {
            return baseTypes.Any(t => t.IsAssignableFrom(type));
        }
    }
}
